package com.karina.visualization.chart.model;

import java.util.ArrayList;
import java.util.List;

public class SeriesModel<DataType> extends ShapeModel<DataType> {

	public static class CategoryValue {
		private String category;
		private String description;
		private Object value;

		public CategoryValue() {

		}

		public CategoryValue(CategoryValue cv) {
			category = cv.getCategory();
			description = cv.getDescription();
			value = cv.getValue();
		}

		public void setCategory(String category) {
			this.category = category;
		}

		public String getCategory() {
			return category;
		}

		public void setValue(Object value) {
			this.value = value;
		}

		public Object getValue() {
			return value;
		}

		public String getDescription() {
			return description;
		}

		public void setDescription(String description) {
			this.description = description;
		}
	}

	private int Index;
	private double relativeX;
	private double relativeY;
	private String name;
	private String type;

	public static final String COLUMN = "Column Series";

	public static final String LINE = "Line Series";

	public void setName(String n) {
		name = n;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}

	public String getName() {
		return name;
	}

	public void setRelativeX(double relativeX) {
		this.relativeX = relativeX;
	}

	public double getRelativeX() {
		return relativeX;
	}

	public void setRelativeY(double relativeY) {
		this.relativeY = relativeY;
	}

	public double getRelativeY() {
		return relativeY;
	}

	public void setIndex(int Index) {
		this.Index = Index;
	}

	public int getIndex() {
		return Index;
	}

	@Override
	protected DataModel<DataType> copy(DataModel<DataType> target) {
		SeriesModel<DataType> seriesM = (SeriesModel<DataType>) super
				.copy(target);
		seriesM.setValue(getValue());
		seriesM.Index = Index;
		seriesM.relativeX = relativeX;
		seriesM.relativeY = relativeY;
		seriesM.name = name;
		seriesM.type = type;
		return seriesM;
	}

	@Override
	public SeriesModel<DataType> cloneMe() {
		SeriesModel<DataType> model = new SeriesModel<DataType>();

		return (SeriesModel<DataType>) copy(model);
	}

	@Override
	public List<ShapeModel<DataType>> createSeriesModelSteps(
			ShapeModel<DataType> target, int numSteps) {
		List<ShapeModel<DataType>> serieses = new ArrayList<ShapeModel<DataType>>();
		for (int i = 0; i < numSteps; i++) {
			serieses.add((ShapeModel<DataType>) createStepModel(target,
					((i + 1.0) / (numSteps))));
		}
		// serieses.add(target);
		return serieses;
	}

	@Override
	protected DataModel<DataType> createStepModel(DataModel<DataType> t,
			double rate) {
		SeriesModel<DataType> newSeriesM = (SeriesModel<DataType>) super
				.createStepModel(t, rate);

		newSeriesM.relativeX = relativeX
				+ ((((SeriesModel<DataType>) t).getRelativeX() - relativeX) * rate);
		newSeriesM.relativeY = relativeY
				+ ((((SeriesModel<DataType>) t).getRelativeY() - relativeY) * rate);

		return newSeriesM;
	}
}
